package com.qfedu.xyeduapi.util;

import redis.clients.jedis.Jedis;

/**
 * @Author：LSM
 * @Date：2022/06/29/19:48
 */
public class JedisUtil {
    private static Jedis jedis;
    static {
        jedis=new Jedis("43.138.42.160",6380);
        jedis.auth("123456");
    }
    //新增
    public static void addString(String key,String val){
        jedis.set(key,val);
    }
    public static void addString(String key,String val,long seconds){
        jedis.setex(key,seconds,val);
    }
    public static void addSet(String key,String val){
        jedis.sadd(key,val);
    }

    //校验
    public static boolean checkKey(String... key){
        return jedis.exists(key)>0;
    }
    public static boolean checkSet(String key,String val){
        return jedis.sismember(key,val);
    }
    //获取
    public static String getString(String key){
        return jedis.get(key);
    }
    //删除
    public static void delKeys(String... keys){
        jedis.del(keys);
    }

}
